home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: netcom.com!marnold
- From: marnold@netcom.com (Matt Arnold)
- Subject: Re: What is : void class::method(TYPE* type) throw()
- Message-ID: <marnoldDov7G4.H3M@netcom.com>
- Organization: NETCOM On-line Communication Services (408 261-4700 guest)
- References: <4j5jfc$hk3@doc.zippo.com>
- Date: Tue, 26 Mar 1996 07:57:40 GMT
- Sender: marnold@netcom16.netcom.com
-
- Gilad Brand writes:
-
- >I read an article in the "C++ Report" which carried the name: "C++ Exception -
- >Handling in Multithreaded Programs" / by Sean Leary.
- >In the article I saw some examples of code which syntax was unfamiliar to me.
- >The formal declaration of a method was written like this:
-
- >void EHThread::terminate(EHThread* self) throw()
- >{
- > ...
- >}
-
- >This syntax returned in other places in the article.
- >I wonder if there is anyone who is familiar with this syntax, and can tell
- >me what is its meaning ?
- >Thanks,
-
- I assume you recognize the syntax for a member function definition and
- that it is the "throw()" that is, er, throwing you.
-
- That syntax is an "exception specification". An exception specification
- lists the exception types a function is allowed to throw. If any
- exception not in the list *is* thrown from within the function (or some
- code called by the function), unexpected() will be called. The default
- behavior of unexpected() is to terminate the program.
-
- The above syntax of an empty list is the special case indicating that
- EHThread::terminate() should throw any exceptions. Someone is trying to
- make it clear that this member is not allowed (or does not) to raise any
- kind of exception.
-
- On the other hand, if the member *was* allowed to throw, say, Foo and
- Bar exceptions, for example, the code would have looked like this...
-
- void EHThread::terminate(EHThread* self) throw(Foo, Bar)
-
- Some folks in the C++ community doubt the usefullness of exception
- specifications. They are somewhat tedious to use and, perhaps, a little
- bit too error-prone (using them causually may cause code to terminate
- when you didn't really want it to). I urge you to read more about them
- in any C++ books you can find that cover them and come to your own
- decisions.
-
- Regards,
- -------------------------------------------------------------------------
- Matt Arnold | | ||| | |||| | | | || ||
- marnold@netcom.com | | ||| | |||| | | | || ||
- Boston, MA | 0 | ||| | |||| | | | || ||
- 617.389.7384 (h) 617.576.2760 (w) | | ||| | |||| | | | || ||
- C++, MIDI, Win32/95 developer | | ||| 4 3 1 0 8 3 || ||
- -------------------------------------------------------------------------
-